home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / fg / fgl402c / exc.arj / TEMP / 08-16.C < prev    next >
Text File  |  1995-01-20  |  2KB  |  85 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #ifdef __TURBOC__
  5. #include <alloc.h>
  6. #else
  7. #include <malloc.h>
  8. #endif
  9.  
  10. #define WIDTH  1000
  11. #define HEIGHT   50
  12.  
  13. void main(void);
  14.  
  15. void main()
  16. {
  17.    int handle;
  18.    int old_mode;
  19.    int x;
  20. #ifdef FG32
  21.    char *buffer;
  22. #else
  23.    char huge *buffer;
  24. #endif
  25.  
  26.    /* initialize the video environment */
  27.  
  28.    fg_initpm();
  29.    old_mode = fg_getmode();
  30.    fg_setmode(20);
  31.    fg_vbinit();
  32.  
  33.    /* fill the screen with light blue pixels */
  34.  
  35.    fg_setcolor(9);
  36.    fg_fillpage();
  37.  
  38.    /* set up the virtual buffer */
  39.  
  40. #ifdef FG32
  41.    buffer = (char *)malloc(WIDTH*HEIGHT);
  42. #elif defined(__TURBOC__)
  43.    buffer = (char huge *)farmalloc((long)WIDTH*(long)HEIGHT);
  44. #else
  45.    buffer = (char huge *)halloc((long)WIDTH*(long)HEIGHT,1);
  46. #endif
  47.    if (buffer == NULL)
  48.    {
  49.       fg_setmode(old_mode);
  50.       fg_reset();
  51.       printf("Could not create the virtual buffer.\n");
  52.       exit(1);
  53.    }
  54.    handle = fg_vbdefine(buffer,WIDTH,HEIGHT);
  55.    fg_vbopen(handle);
  56.  
  57.    /* fill the virtual buffer with a series of narrow rectangles */
  58.  
  59.    for (x = 0; x < WIDTH; x++)
  60.    {
  61.       fg_setcolor(x);
  62.       fg_rect(x,x,0,HEIGHT-1);
  63.    }
  64.  
  65.    /* scroll the virtual buffer through a 100x50 window on the */
  66.    /* visual page, such that the top half scrolls left and the */
  67.    /* bottom half scrolls right */
  68.  
  69.    for (x = 0; x < WIDTH-99; x++)
  70.    {
  71.       fg_vbpaste(x,x+99,0,24,110,99);
  72.       fg_vbpaste(WIDTH-100-x,WIDTH-1-x,25,49,110,124);
  73.    }
  74.    fg_waitkey();
  75.  
  76.    /* close the virtual buffer */
  77.  
  78.    fg_vbclose();
  79.  
  80.    /* restore original video mode and exit */
  81.  
  82.    fg_setmode(old_mode);
  83.    fg_reset();
  84. }
  85.